<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>供需对接服务系统--项目列表</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        width: 100%;
        overflow-y: scroll;
    }
    .widthle{
        width: 50%;
    }
    .widinput{
        width: 42%!important;
    }

</style>

<body>
<!--头部-->

<!--容器-->
<div class="container clearfix">
    <!--右侧内容-->
    <div class="Right fr mt10">
        <div class="screening screeningOne whitebg clearfix">
            <ul class="clearfix fl" style="width: 100%;">
                <li style="width: 20%;">
                    <label class="fl widthle" >项目归属:</label>
                    <select name="projectOwner" id="projectOwner"  class="widinput">
                        <option value="">全部</option>
                        <#list com as vo>
                            <option value="${vo.bcId}">${vo.bcName}</option>
                        </#list>
                    </select>
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">项目名称:</label>
                    <input type="text"  class="widinput" style="border: 1px solid #DDDDDD" name="projectName" id="projectName"
                           autocomplete="off" placeholder="全部">
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">项目类型:</label>
                    <select name="projectType" id="projectType" onchange="QueryYw()" class="widinput">
                        <option value="">全部</option>
                        <#list projectTypeList as vo>
                            <option value="${vo.badtCode}">${vo.badtName}</option>
                        </#list>
                    </select>
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">业务类型:</label>
                    <select id="checkShape">
                        <option value="">请选择</option>
                    </select>
                </li>

                <li style="width: 20%;">
                    <label class="fl widthle" >行业:</label>
                    <select name="hyType" id="hyType"  class="widinput">
                        <option value="">全部</option>
                        <#list HyTypelist as vo>
                            <option value="${vo.badtCode}">${vo.badtName}</option>
                        </#list>
                    </select>
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">项目状态:</label>
                    <select name="status" id="status"  class="widinput">
                        <option value="">全部</option>
                        <option value="001">未提交</option>
                        <option value="002">未启动</option>
                        <option value="003">已完成</option>
                        <option value="004">进行中</option>
                        <option value="005">已延期</option>
                    </select>
                </li>
            </ul>
            <ul class="clearfix fl mt10" style="width: 100%;">

                <li style="width: 20%;">
                    <label class="fl widthle" >项目经理:</label>
                    <input type="text"  class="widinput" style="border: 1px solid #DDDDDD" name="projectManagerPersonName" id="projectManagerPersonName"
                           autocomplete="off" placeholder="全部">
                </li>
                <li style="width: 20%;">
<#--                    <label class="fl widthle" >检测工程师:</label>-->
<#--                    <select id = "jcAdviser"style=";border: 1px solid #DDDDDD"  class="widinput">-->
<#--                        <option value="">全部</option>-->
<#--                        <#list userJc as pjtvo>-->
<#--                            <option value="${pjtvo.id}">${pjtvo.realName}</option>-->
<#--                        </#list>-->
<#--                    </select>-->
                    <label class="fl widthle" >技术负责人:</label>
                    <input type="text"   class="widinput" style=";border: 1px solid #DDDDDD" name="technologyPersonName" id="technologyPersonName"
                           autocomplete="off" placeholder="全部">
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">是否延期:</label>
                    <select name="isYq" id="isYq" class="widinput">
                        <option value="">全部</option>
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle" >回款及时性:</label>
                    <select name="hkjsx" id="hkjsx" class="widinput">
                        <option value="">全部</option>
                        <option value="001">提前</option>
                        <option value="002">按时</option>
                        <option value="003">延期</option>
                    </select>
                </li>

            </ul>
            <ul class="clearfix fl mt10" style="width: 100%;">

                <li style="width: 20%;">
                    <label class="fl widthle">省份:</label>
                    <select name="province" class="ml8 widinput" id="province"  onchange="provinceChange(this)"  class="widinput"
                            lay-verify="required" lay-ignore>
                        <option value="">全部</option>
                        <#list provincelist as vo>
                            <option value="${vo.code}">${vo.name}</option>
                        </#list>
                    </select>
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">城市:</label>
                    <select name="city" id="city" class="ml8 widinput" lay-filter="city" lay-verify="required"
                            style="margin-left: 0px" lay-ignore   onchange="cityChange(this)">
                        <option value="">全部</option>
                    </select>
                </li>
                <li style="width: 20%;">
                    <label class="fl widthle">区县:</label>
                    <select name="county" id="county" class="ml8 widinput" lay-filter="county" lay-verify="required"
                            style="margin-left: 0px" lay-ignore>
                        <option value="">全部</option>
                    </select>
                </li>

            </ul>
            <ul class="clearfix fl mt10" style="width: 100%;">
                <li style="width: 33%;">
                    <label class="fl widthle"   style="width: 22%;">投资额(元):</label>
                    <input type="text"   style="border: 1px solid #DDDDDD;width:120px" name="tzMoneyMin" id="tzMoneyMin"
                           autocomplete="off" placeholder="最小值">
                    至
                    <input type="text"  style="border: 1px solid #DDDDDD;width:120px;" name="tzMoneyMax" id="tzMoneyMax"
                           autocomplete="off" placeholder="最大值">

                </li>
                <li style="width: 33%;">
                    <label class="fl widthle"   style="width: 22%;" >进度(%):</label>
                    <input type="text"   style="border: 1px solid #DDDDDD;width:120px" name="progressMin" id="progressMin"
                           autocomplete="off" placeholder="最小值">
                    至
                    <input type="text"  style="border: 1px solid #DDDDDD;width:120px" name="progressMax" id="progressMax"
                           autocomplete="off" placeholder="最大值">
                </li>
                <li style="width: 33%;">
                    <label class="fl widthle"   style="width: 27%;" >服务费(元):</label>
                    <input type="text"   style="border: 1px solid #DDDDDD; width:120px" name="htMoneyMin" id="htMoneyMin"
                           autocomplete="off" placeholder="最小值">
                    至
                    <input type="text"  style="border: 1px solid #DDDDDD;width:120px;" name="htMoneyMax" id="htMoneyMax"
                           autocomplete="off" placeholder="最大值">
                </li>

            </ul>
            <ul class="clearfix fl mt10" style="width: 100%;">
                <li style="width: 33%;">
                    <label class="fl widthle" style="width: 22%;">回款比例(%):</label>
                    <input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="hkblmin" id="hkblmin"
                           autocomplete="off" placeholder="最小值">
                    至
                    <input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="hkblmax" id="hkblmax"
                           autocomplete="off" placeholder="最大值">
                </li>
                <li style="width: 33%;">
                    <label class="fl widthle" style="width: 22%;">取费比例(%):</label>
                    <input type="text" style="border: 1px solid #DDDDDD;width:120px;" name="qfblmin" id="qfblmin"
                           autocomplete="off" placeholder="最小值">
                    至
                    <input type="text" style="border: 1px solid #DDDDDD;width: 120px;" name="qfblmax" id="qfblmax"
                           autocomplete="off" placeholder="最大值">
                </li>

            </ul>
            <ul class="clearfix fl mt10" style="width: 100%;">
                <li style="width: 30%;">
                    <label class="fl" style="width: 20%;">时间段:</label>
                    <input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="startDate" id="startDate"
                           autocomplete="off" placeholder="开始时间">
                    至
                    <input type="text" style="border: 1px solid #DDDDDD;width:120px;" name="endDate" id="endDate"
                           autocomplete="off" placeholder="结束时间">
                </li>
                <li style="width: 42%; ">
                    <label class="fl widthle" style="width: 22%;">文档统计时间:</label>
                    <select name="type"     id="selectedOption"    onchange="selectChange()" nchange style="padding:0px 10px;width:140px">
                        <option value="day"  selected   >按日统计</option>
                        <option value="week"  >按周统计</option>
                        <option value="month"  >按月统计</option>
                        <option value="quarter"  >按季度统计</option>
                        <option value="year"  >按年统计</option>
                    </select>
                    <span  id="datetable1">

                                    <input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="startWjDate" id="startWjDate"
                                           autocomplete="off" placeholder="开始时间">
                    </span>
                    <sapn  id="zhi">
                        至

                    </sapn>

                    <span  id="datetable2">
                    <input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="endWjDate" id="endWjDate"
                           autocomplete="off" placeholder="结束时间">
                            </span>
                </li>

                <li style="width: 25%;">
                    <div class="fr mt30">
                        <button type="button" class="layui-btn layui-btn-normal" style="width:65px; height:40px"
                                onclick="query()">筛选
                        </button>
                        <button type="button" class="layui-btn layui-btn-normal" onclick="resetQuery()"
                                style="width:65px; height:40px;background-color: #FF5722;">重置
                        </button>
                    </div>
                </li>

            </ul>
        </div>

        <div class="project whitebg">
            <div class="layui-row">
                <div class="layui-col-md3 layui-col-md-offset9">
                    <@shiro.hasPermission name="search:export">
                    <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportExcelPro()">
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="search:view">
                    <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewExcelPro()">
                    </@shiro.hasPermission>
                </div>
            </div>
            <table id="tableList" class="layui-hide" lay-filter="tableList"></table>
        </div>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript">
    var layer;
    var form = layui.form;
    var table = null;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    var laydate = null;
    layui.use('element', function () {
        element = layui.element;


    });
    layui.use('laydate', function () {
         laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#beginDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });
        laydate.render({
            elem: '#startWjDate' //指定元素
        });
        laydate.render({
            elem: '#endWjDate' //指定元素
        });
        let genTimeEnd = genTime('day');
        $("#endWjDate").val(genTimeEnd)
        let genTimeStart = genTimeLastDay('day');
        $("#startWjDate").val(genTimeStart)
    });

    function selectChange() {

        let opt = $("#selectedOption").val();
        let ele = $("#selectedOption");
        $("#startWjDate").remove()
        if (opt == "year"){
            $("#datetable1").html('<input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="startWjDate" id="startWjDate"  autocomplete="off" placeholder="年度">');
            $("#zhi").html("");
        }else if(opt == "quarter"){
            $("#datetable1").html('<input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="startWjDate" id="startWjDate"  autocomplete="off" placeholder="季度">');
            $("#zhi").html("");

        }else if(opt == "month"){
            $("#datetable1").html('<input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="startWjDate" id="startWjDate"  autocomplete="off" placeholder="月度">');
            $("#zhi").html("");

        }else if(opt == "week"){
            $("#datetable1").html('<input type="text" style="border: 1px solid #DDDDDD;width: 300px" name="startWjDate" id="startWjDate"  autocomplete="off" placeholder="周">');
            $("#zhi").html("");

        }else{
            $("#datetable1").html('<input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="startWjDate" id="startWjDate"  autocomplete="off" placeholder="开始时间">');
            $("#zhi").html("至")
        }
        $("#endWjDate").remove()
        $("#datetable2").html('<input type="text" style="border: 1px solid #DDDDDD;width: 120px" name="endWjDate" id="endWjDate"  autocomplete="off" placeholder="结束时间">');
        // 月
        if (opt == "month") {
            $("#endWjDate").remove()
            laydate.render({
                elem: '#startWjDate',
                type: 'month',
                max: genTime('month'),
                value: genTime('month'),
                btns: ['clear', 'confirm']
            });

            // 日
        } else if (opt == "day") {
            laydate.render({
                elem: '#startWjDate',
                type: 'date',
                max: genTime('day'),
                value: genTime('day'),
                btns: ['clear', 'confirm']
            });
            laydate.render({
                elem: '#endWjDate',
                type: 'date',
                max: genLastTime('day'),
                value: genLastTime('day'),
                btns: ['clear', 'confirm']
            });
            // 周
        } else if (opt == "week") {
            renderWeekDate('#startWjDate', '');
            $("#endWjDate").remove()
            // 季度
        } else if (opt == "quarter") {

            renderSeasonDate('#startWjDate', '');
            $("#endWjDate").remove()

            // 年
        } else if (opt == "year") {
            let ele = $("#startWjDate");
            $("#endWjDate").remove()
            laydate.render({
                elem: '#startWjDate',
                type: 'year',
                max: genTime('day'),
                value: genTime('year'),
                format: "yyyy-MM-dd",
                btns: ['clear', 'confirm']

            });
            laydate.render({
                elem: '#endWjDate',
                type: 'year',
                max: genTime('day'),
                value: genTime('year'),
                btns: ['clear', 'confirm']
            });
        }

    }
    function renderWeekDate(ohd, sgl) {
        let ele = $(ohd);
        laydate.render({
            elem: ohd,
            type: 'date',
            max: genTime('day'),
            format: "yyyy-MM-dd~yyyy-MM-dd",
            btns: ['clear', 'confirm'],
            done: function (value, date, endDate) {
                if (value != "" && value.length > 0) {
                    let today = new Date(value.substring(0, 10));
                    let weekday = today.getDay();
                    let monday;
                    let sunday;
                    if (weekday == 0) {
                        monday = new Date(1000 * 60 * 60 * 24 * (weekday - 6) + today.getTime());
                    } else {
                        monday = new Date(1000 * 60 * 60 * 24 * (1 - weekday) + today.getTime());
                    }
                    if (weekday == 0) {
                        sunday = today;
                    } else {
                        sunday = new Date(1000 * 60 * 60 * 24 * (7 - weekday) + today.getTime());
                    }
                    let month = monday.getMonth() + 1;
                    if (month < 10) {
                        month = "0" + month;
                    }
                    let day1 = monday.getDate();
                    if (day1 < 10) {
                        day1 = "0" + day1;
                    }
                    let start = "" + monday.getFullYear() + "-" + month + "-" + day1;
                    let month2 = sunday.getMonth() + 1;
                    if (month2 < 10) {
                        month2 = "0" + month2;
                    }
                    let day2 = sunday.getDate();
                    if (day2 < 10) {
                        day2 = "0" + day2;
                    }
                    let end = "" + sunday.getFullYear() + "-" + month2 + "-" + day2;
                    ele.val(start + "~" + end);
                } else {
                    ele.val('');
                }
            }
        });
    }

    function renderWeekDateEnd(ohd, sgl) {
        let ele = $(ohd);
        laydate.render({
            elem: ohd,
            type: 'date',
            max: genTime('day'),
            format: "yyyy-MM-dd",
            btns: ['clear', 'confirm'],
            done: function (value, date, endDate) {
                if (value != "" && value.length > 0) {
                    let today = new Date(value.substring(0, 10));
                    let weekday = today.getDay();
                    let monday;
                    let sunday;
                    if (weekday == 0) {
                        monday = new Date(1000 * 60 * 60 * 24 * (weekday - 6) + today.getTime());
                    } else {
                        monday = new Date(1000 * 60 * 60 * 24 * (1 - weekday) + today.getTime());
                    }
                    if (weekday == 0) {
                        sunday = today;
                    } else {
                        sunday = new Date(1000 * 60 * 60 * 24 * (7 - weekday) + today.getTime());
                    }
                    let month = monday.getMonth() + 1;
                    if (month < 10) {
                        month = "0" + month;
                    }
                    let day1 = monday.getDate();
                    if (day1 < 10) {
                        day1 = "0" + day1;
                    }
                    let start = "" + monday.getFullYear() + "-" + month + "-" + day1;
                    let month2 = sunday.getMonth() + 1;
                    if (month2 < 10) {
                        month2 = "0" + month2;
                    }
                    let day2 = sunday.getDate();
                    if (day2 < 10) {
                        day2 = "0" + day2;
                    }
                    let end = "" + sunday.getFullYear() + "-" + month2 + "-" + day2;
                    $("#startWjDate").val(start)
                    ele.val(end);
                } else {
                    ele.val('');
                }
            }
        });
    }




    // 季度
    function renderSeasonDate(ohd, sgl) {
        let ele = $(ohd);
        laydate.render({
            elem: ohd,
            type: 'month',
            format: 'yyyy-M',
            btns: ['clear', 'confirm'],
            ready: function (value, date, endDate) {
                let hd = $("#layui-laydate" + ele.attr("lay-key"));
                if (hd.length > 0) {
                    hd.click(function () {
                        quarter($(this));
                    });
                }
                quarter(hd);
            },
            done: function (value, date, endDate) {
                if (!isNull(date) && date.month > 0 && date.month < 5) {
                    ele.attr("startDate", date.year + "-" + date.month);
                } else {
                    ele.attr("startDate", "");
                }
                if (!isNull(endDate) && endDate.month > 0 && endDate.month < 5) {
                    ele.attr("endDate", endDate.year + "-" + endDate.month)
                } else {
                    ele.attr("endDate", "");
                }
            }
        });
    }

    function genLastTime(opt) {
        let now = new Date();
        let year = now.getFullYear();
        let mth = now.getMonth();
        let day = now.getDate()-1;
        let month = mth + 1;
        if (month < 10) {
            month = '0' + month
        }
        if (day < 10) {
            day = '0' + day
        }
        let str;
        if (opt == 'day') {
            str = year + '-' + month + '-' + day;
        } else if (opt == 'month') {
            str = year + '-' + month;
        }
        return str;
    }
    function genTime(opt) {
        let now = new Date();
        let year = now.getFullYear();
        let mth = now.getMonth();
        let day = now.getDate();
        let month = mth + 1;
        if (month < 10) {
            month = '0' + month
        }
        if (day < 10) {
            day = '0' + day
        }
        let str;
        if (opt == 'day') {
            str = year + '-' + month + '-' + day;
        } else if (opt == 'month') {
            str = year + '-' + month;
        }
        return str;
    }
    function genTimeLastDay(opt) {
        let now = new Date();
        let year = now.getFullYear();
        let mth = now.getMonth();
        let day = now.getDate()-1;
        let month = mth + 1;
        if (month < 10) {
            month = '0' + month
        }
        if (day < 10) {
            day = '0' + day
        }
        let str;
        if (opt == 'day') {
            str = year + '-' + month + '-' + day;
        } else if (opt == 'month') {
            str = year + '-' + month;
        }
        return str;
    }
    function quarter(thiz) {
        let mls = thiz.find(".laydate-month-list");
        mls.each(function (i, e) {
            $(this).find("li").each(function (inx, ele) {
                let cx = ele.innerHTML;
                if (inx < 4) {
                    ele.innerHTML = cx.replace(/月/g, "季度");
                } else {
                    ele.style.display = "none";
                }
            });
        });
    }
    function isNull(quarter) {
        if (quarter == null || typeof (quarter) == "undefined" || quarter == "") return true;
        return false;
    }
    /**
     * 日期转为周 格式2020-07-14
     * @param {String} dateString 日期
     */
    function getYearWeek(dateString) {
        let da = dateString;//日期格式2015-12-30
        //当前日期
        let date1 = new Date(da.substring(0, 4), parseInt(da.substring(5, 7)) - 1, da.substring(8, 10));
        //1月1号
        let date2 = new Date(da.substring(0, 4), 0, 1);
        //获取1月1号星期（以周一为第一天，0周一~6周日）
        let dateWeekNum = date2.getDay() - 1;
        if (dateWeekNum < 0) { dateWeekNum = 6; }
        if (dateWeekNum < 4) {
            //前移日期
            date2.setDate(date2.getDate() - dateWeekNum);
        } else {
            //后移日期
            date2.setDate(date2.getDate() + 7 - dateWeekNum);
        }
        let d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
        if (d < 0) {
            let date3 = (date1.getFullYear() - 1) + "-12-31";
            return getYearWeek(date3);
        } else {
            //得到年数周数
            let year = date1.getFullYear();
            let week = Math.ceil((d + 1) / 7);
            return year + "-" + week;
        }
    }



    function query() {
        // 项目归属
        var projectOwner = $('#projectOwner').val();
        //项目名称
        var projectName = $('#projectName').val();
        //项目类型
        var projectType = $('#projectType').val();
        //h行业类型
        var hyType = $('#hyType').val();
        // 状态
        var status = $('#status').val();
        //项目经理
        var projectManagerPersonName = $('#projectManagerPersonName').val();

        var jcAdviser = $("#jcAdviser").val();
        var technologyPersonName = $("#technologyPersonName").val();
        //项目进度
        var progress = $('#progress').val();
        // 是否延期
        var isYq = $('#isYq').val();
        var checkShape = $("#checkShape").val();
        // 投资额
        var tzMoneyMin = $('#tzMoneyMin').val();
        var tzMoneyMax = $('#tzMoneyMax').val();
        //检测服务费
        var htMoneyMin = $('#htMoneyMin').val();
        var htMoneyMax = $('#htMoneyMax').val();
        // 项目进度
        var progressMin = $('#progressMin').val();
        var progressMax = $('#progressMax').val();
        // 汇款及时性
        var hkjsx = $('#hkjsx').val();
        // 省
        var province = $('#province').val();
        // 市
        var city = $('#city').val();
        // 县
        var county = $('#county').val();

        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();



        var hkblmin = $('#hkblmin').val();
        var hkblmax = $('#hkblmax').val();

        var qfblmin = $('#qfblmin').val();

        var qfblmax = $('#qfblmax').val();

        var tjType = $('#selectedOption').val();
        var startWjDate = $('#startWjDate').val();
        var endWjDate = $('#endWjDate').val();


        var jsondata = {
            projectOwner:projectOwner,
            projectName: projectName,
            projectType: projectType,
            hyType:hyType,
            status:status,
            projectManagerPersonName:projectManagerPersonName,
            jcAdviser:jcAdviser,
            progress:progress,
            isYq:isYq,
            tzMoneyMin:tzMoneyMin,
            tzMoneyMax:tzMoneyMax,
            htMoneyMin:htMoneyMin,
            htMoneyMax:htMoneyMax,
            progressMin:progressMin,
            progressMax:progressMax,
            hkjsx:hkjsx,
            province: province,
            city: city,
            county: county,
            startDate: startDate,
            endDate: endDate,
            checkShape:checkShape,
            technologyPersonName:technologyPersonName,
            hkblmin:hkblmin,
            hkblmax:hkblmax,
            qfblmin:qfblmin,
            qfblmax:qfblmax,
            tjType:tjType,
            startWjDate:startWjDate,
            endWjDate:endWjDate
        };
        table.reload('tableList', {where: jsondata});
    }

    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });
    });

    layui.use('table', function () {
        table = layui.table;
        element = element;
        var startWjDate = $('#startWjDate').val();
        var endWjDate = $('#endWjDate').val();
        var tjType = $('#selectedOption').val();
        var  queryjson={
            startWjDate:startWjDate,
            endWjDate:endWjDate,
            tjType:tjType
        }
        //方法级渲染
        tableIns = table.render({
            id: 'tableList',
            elem: '#tableList',
            url: '/search/buProjectInfo/showProjectJcTjList',
            height: "auto",
            page: true,
            where:queryjson,
            autoSort: false,
            cols: [[
                {
                    title: '序号', width: '100', templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {field: 'id', title: 'id', width: '100', hide: true, sort: true},
                {field: 'totalDurationBeginDate', title: '年份', width: '100', sort: false,templet:"<div>{{layui.util.toDateString(d.totalDurationBeginDate,'yyyy')}}</div>"},
                {field: 'projectOwnerName', title: '项目归属', width: '100', sort: false},
                {
                    field: 'projectName', title: '项目名称', width: '300', sort: false, templet: function (d) {
                        return '<span class="cursor" style="color: blue;" onclick="showDetail(\'' + d.id + '\',\'' + d.projectName + '\')">' + d.projectName + '</span>';
                    }
                },
                {
                    field: 'projectTypeName', title: '项目类型', width: '100', sort: false
                },
                {
                    field: 'badtName', title: '业务类型', width: '120', sort: true, align: "center"
                },
                {
                    field: 'hyTypeName', title: '行业', width: '80', sort: false
                },
                {
                    field: 'status', title: '项目状态', width: '100', sort: false, templet: function (d) {
                        if (d.status == "000") {
                            return '已删除'
                        }
                        if (d.status == "001") {
                            return '未提交'
                        }
                        if (d.status == "002") {
                            return '未启动'
                        }
                        if (d.status == "004") {
                            return '进行中'
                        }
                        if (d.status == "003") {
                            return '已完成'
                        }
                        if (d.status == "005") {
                            return '已延期'
                        }
                    }
                },
                {field: 'projectManagerPersonName', title: '项目经理', width: '100', sort: false},
                {field: 'technologyPersonName', title: '技术负责人', width: '120', sort: false},
                {field: 'progress', title: '项目进度', width: '120', sort: true, templet: function (d) {
                        return  d.progress+"%";
                    }},
                {field: 'isYq', title: '是否延期', width: '100', sort: false, templet: function (d) {
                        if(d.status=='005'){
                            return '是';
                        }else{
                            return '否';
                        }
                    }},
                {field: 'tzMoney', title: '投资额（元）', width: '150', sort: true, templet: function (d) {
                       if (d.tzMoney){
                           return d.tzMoney;
                       }else{
                           return '0';
                       }
                    }},
                {field: 'htMoney', title: '检测合同额（元）', width: '180', sort: true, templet: function (d) {
                    if(d.htMoney){
                        return d.htMoney;
                    }else{
                        return '0';
                    }

                    }},

                {field: 'qfbl', title: '取费比例', width: '100', sort: false, templet: function (d) {
                    if(parseFloat(d.htMoney)/parseFloat(d.tzMoney)){
                        return cutZero(((parseFloat(d.htMoney)/parseFloat(d.tzMoney))*100).toFixed(2))+"%";
                    }else{
                        return "0%";
                    }

                    }},
                {field: 'ykfpje', title: '已开发票金额（元）', width: '190', sort: true, templet: function (d) {
                        return '<span class="cursor" style="color: blue;" onclick="ylfpje(\'' + d.id + '\')">' + d.ykfpje + '</span>';
                    }},
                {field: 'wkfpje', title: '未开发票金额（元）', width: '180', sort: false ,templet: function (d) {

                        var  kk= parseFloat(d.htMoney)- parseFloat(d.ykfpje);
                        if(!kk || kk<0){
                            kk=0;
                        }
                        return '<span class="cursor" style="color: blue;" onclick="noylfpje(\'' + d.id + '\')">' + kk + '</span>';
                    }},

                {field: 'yhkje', title: '已回款金额（元）', width: '180', sort: true, templet: function (d) {
                        return '<span class="cursor" style="color: blue;" onclick="viewYhkje(\'' + d.id + '\')">' + parseFloat(d.yhkje)+ '</span>';
                    }},
                {field: 'yhkbl', title: '已回款比例', width: '130', sort: false, templet: function (d) {
                    if(parseFloat(d.yhkje)/parseFloat(d.htMoney)){
                        return ((parseFloat(d.yhkje)/parseFloat(d.htMoney))*100).toFixed(2)+"%";
                    }else{
                        return "0%"
                    }

                    }},
                {field: 'dhkje', title: '待回款金额（元）', width: '160', sort: false, templet: function (d) {
                        var ss=parseFloat(d.htMoney)-parseFloat(d.yhkje);
                        if(!ss){
                            ss=0;
                        }
                        return '<span class="cursor" style="color: blue;" onclick="viewNohkje(\'' + d.id + '\')">' +ss + '</span>';
                    }},
                {field: 'dhkbl', title: '待回款比例', width: '150', sort: false, templet: function (d) {
                    if((parseFloat(d.htMoney)-parseFloat(d.yhkje))/parseFloat(d.htMoney)){
                        return (((parseFloat(d.htMoney)-parseFloat(d.yhkje))/parseFloat(d.htMoney))*100).toFixed(2)+"%";
                    }else{
                        return "0%";
                    }

                    }},
                {field: 'hkjsx', title: '回款及时性', width: '130', sort: false,templet: function (d) {
                        if(d.hkjsx=='001'){
                            return "提前";
                        }else if(d.hkjsx=='002'){
                            return "按时";
                        }else if(d.hkjsx=='003'){
                            return "延期";
                        }

                    }},
                {field: 'provinceName', title: '省份', width: '100', sort: false},
                {field: 'cityName', title: '城市', width: '100', sort: false},
                {field: 'countyName', title: '区县', width: '100', sort: false},
                {
                    field: 'totalWdNum', title: '项目文档总数量', width: '180', sort: true},
                {
                    field: 'totalNum', title: '检测文档总数量', width: '180', sort: true},

                {
                    field: 'startWjNum', title: '开始文档数量', width: '180', sort: true},

                {
                    field: 'endWjNum', title: '结束文档数量', width: '180', sort: true},
                {
                    field: 'updateWjNum', title: '文档更新数量', width: '180', sort: true
                },

                {
                    field: 'uploadBeginTime', title: '文档开始上传时间', width: '180', sort: true},
                {
                    field: 'uploadLastTime', title: '文档最后上传时间', width: '180', sort: true},

                {
                    field: 'totalDurationBeginDate', title: '开工时间', width: '180', sort: true},

                {
                    field: 'totalDurationEndDate', title: '竣工时间', width: '180', sort: true},
                {
                    field: 'totalDate', title: '项目工期', width: '180', sort: true}
            ]],
            done: function (res, currentCount) {
                //***重点***：table渲染完成后渲染element进度条
                element.render();
                $(".layui-table-page select").css("width", "80px");

            }
        });
        // 监听排序 解决 项目进度排序后不显示的问题
        table.on('sort(tableList)', function (obj) {
            //遍历设置目前的宽度：
            // saveTableWidth();
            table.reload('tableList', {
                initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                , where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                    field: obj.field,//排序字段
                    order: obj.type//排序方式
                },
                // cols: tableIns.cols
            });
        });
        //监听工具条
        table.on('tool(tableList)', function (obj) {
            var data = obj.data;
            var that = $(this);
            if (obj.event === 'resetPassword') {
                parent.layer.confirm('确定重置密码？', function (index) {
                    var userId = data.userId;
                    layerAjax("resetPassword", {id: userId}, "", function (d) {
                        if (d.flag) {
                            parent.layer.close(index);
                            layer.msg("操作成功", {icon: 1});
                            tableIns.reload();
                        } else {
                            layer.msg("操作失败", {icon: 2});
                        }
                    })
                });
            }
        });
    });


    function showDetail(id, projectName) {
        window.parent._showtab('xm_v' + id, '查看-' +projectName, '/jc/projectManager/projectDetail?type=v&id=' +id);
    }
    // 已开发票金额
    function ylfpje(id) {
        var projectId = id;
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width()-200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var url = "/search/buProjectInfo//viewYKfPJc?projectId=" + projectId;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function(layero){
                layero.find('.layui-layer-min').remove();
            }
        });


    }

    function QueryYw() {
        var code = $("#projectType").val();
        layerAjaxGet('/sys/register/getYw', {"code": code}, '', function (data) {
            $("#checkShape").empty();
            $("#checkShape").append("<option value=''>请选择</option>");
            var valData = data.data;
            for (var i = 0; i < valData.length; i++) {
                $("#checkShape").append("<option value='" + valData[i].badtCode + "'>" + valData[i].badtName + "</option>");
            }
        })
    }
    // 未开发票金额
    function noylfpje(id) {
        var projectId = id;
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width()-200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var url = "/search/buProjectInfo/noviewYKfPJc?projectId=" + projectId;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function(layero){
                layero.find('.layui-layer-min').remove();
            }
        });


    }

    // 已回款金额
    function viewYhkje(id) {
        var projectId = id;
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width()-200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var url = "/search/buProjectInfo/viewYhkjeJc?projectId=" + projectId;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function(layero){
                layero.find('.layui-layer-min').remove();
            }
        });

    }

    // 待回款金额
    function viewNohkje(id) {
        var projectId = id;
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width()-200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var url = "/search/buProjectInfo/viewNohkjeJc?projectId=" + projectId;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function(layero){
                layero.find('.layui-layer-min').remove();
            }
        });
    }



    function provinceChange(object) {
        var code = $(object).find('option:selected').val();
        if (code == "") {
            $("#city").empty().append("<option value=''>全部</option>");
            $("#county").empty().append("<option value=''>全部</option>");
            return;
        }
        layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
            if (d.flag == true) {
                $("#city").empty().append("<option value=''>选择市</option>");
                for (var i = 0; i < d.data.length; i++) {
                    $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                }
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });


    };

    function cityChange(object) {
        var code = $(object).find('option:selected').val();
        if (code == "") {
            $("#county").empty().append("<option value=''>全部</option>");
            return;
        }
        layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
            if (d.flag == true) {
                $("#county").empty().append("<option value=''>选择区县</option>");
                for (var i = 0; i < d.data.length; i++) {
                    $("#county").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                }
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });


    }
    //预览
    function viewExcelPro(){
        // 项目归属
        var projectOwner = $('#projectOwner').val();
        //项目名称
        var projectName = $('#projectName').val();
        //项目类型
        var projectType = $('#projectType').val();
        //h行业类型
        var hyType = $('#hyType').val();
        // 状态
        var status = $('#status').val();
        //项目经理
        var projectManagerPersonName = $('#projectManagerPersonName').val();
        // 总监理工程师
        var supervisorEngineerName = $('#supervisorEngineerName').val();
        // 技术负责人
        var technologyPersonName = $('#technologyPersonName').val();
        //项目进度
        var progress = $('#progress').val();
        // 是否延期
        var isYq = $('#isYq').val();
        // 投资额
        var tzMoneyMin = $('#tzMoneyMin').val();
        var tzMoneyMax = $('#tzMoneyMax').val();
        //监理服务费
        var jlFwMoneyMin = $('#jlFwMoneyMin').val();
        var jlFwMoneyMax = $('#jlFwMoneyMax').val();
        // 项目进度
        var progressMin = $('#progressMin').val();
        var progressMax = $('#progressMax').val();
        // 汇款及时性
        var hkjsx = $('#hkjsx').val();
        // 省
        var province = $('#province').val();
        // 市
        var city = $('#city').val();
        // 县
        var county = $('#county').val();
        var checkShape = $("#checkShape").val();
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();
        var hkblmin = $('#hkblmin').val();
        var hkblmax = $('#hkblmax').val();

        var qfblmin = $('#qfblmin').val();

        var qfblmax = $('#qfblmax').val();

        var tjType = $('#selectedOption').val();
        var startWjDate = $('#startWjDate').val();
        var endWjDate = $('#endWjDate').val();
        var jsondata = {
            projectOwner:projectOwner,
            projectName: projectName,
            projectType: projectType,
            hyType:hyType,
            status:status,
            projectManagerPersonName:projectManagerPersonName,
            supervisorEngineerName:supervisorEngineerName,
            progress:progress,
            isYq:isYq,
            tzMoneyMin:tzMoneyMin,
            tzMoneyMax:tzMoneyMax,
            htMoneyMin:jlFwMoneyMin,
            htMoneyMin:jlFwMoneyMax,
            progressMin:progressMin,
            progressMax:progressMax,
            hkjsx:hkjsx,
            province: province,
            city: city,
            county: county,
            startDate: startDate,
            endDate: endDate,
            technologyPersonName:technologyPersonName,
            checkShape:checkShape,
            hkblmin:hkblmin,
            hkblmax:hkblmax,
            qfblmin:qfblmin,
            qfblmax:qfblmax,
            tjType:tjType,
            startWjDate:startWjDate,
            endWjDate:endWjDate
        };
        layerAjaxGet('/search/buProjectInfo/viewTableJcxm?',jsondata,'',function (res) {
            if(res.flag){
                if(res.data){
                    var w = ($(window).width()*0.8);
                    var h = ($(window).height()*0.8);
                    POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
                }
            }
        })
    }
    // 导出
    function exportExcelPro(){
        // 项目归属
        var projectOwner = $('#projectOwner').val();
        //项目名称
        var projectName = $('#projectName').val();
        //项目类型
        var projectType = $('#projectType').val();
        //h行业类型
        var hyType = $('#hyType').val();
        // 状态
        var status = $('#status').val();
        //项目经理
        var projectManagerPersonName = $('#projectManagerPersonName').val();
        // 总监理工程师
        var supervisorEngineerName = $('#supervisorEngineerName').val();
        //项目进度
        var progress = $('#progress').val();
        //技术负责人
        var technologyPersonName = $('#technologyPersonName').val();
        // 是否延期
        var isYq = $('#isYq').val();
        // 投资额
        var tzMoneyMin = $('#tzMoneyMin').val();
        var tzMoneyMax = $('#tzMoneyMax').val();
        //监理服务费
        var jlFwMoneyMin = $('#jlFwMoneyMin').val();
        var jlFwMoneyMax = $('#jlFwMoneyMax').val();
        // 项目进度
        var progressMin = $('#progressMin').val();
        var progressMax = $('#progressMax').val();
        // 汇款及时性
        var hkjsx = $('#hkjsx').val();
        // 省
        var province = $('#province').val();
        // 市
        var city = $('#city').val();
        // 县
        var county = $('#county').val();
        var checkShape = $("#checkShape").val();
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();
        var hkblmin = $('#hkblmin').val();
        var hkblmax = $('#hkblmax').val();

        var qfblmin = $('#qfblmin').val();

        var qfblmax = $('#qfblmax').val();

        var tjType = $('#selectedOption').val();
        var startWjDate = $('#startWjDate').val();
        var endWjDate = $('#endWjDate').val();



        //获取全部数据:
        var url= '/search/buProjectInfo/exportTableJc?projectOwner='+projectOwner+"&projectName="+projectName+"&projectType="+projectType+"&hyType="+hyType+"&status="+status
            +"&projectManagerPersonName="+projectManagerPersonName+"&supervisorEngineerName="+supervisorEngineerName+"&progress="+progress+"&isYq="+isYq+"&technologyPersonName="+technologyPersonName
            + "&tzMoneyMin="+tzMoneyMin+"&tzMoneyMax="+tzMoneyMax+"&jlFwMoneyMin="+jlFwMoneyMin+"&jlFwMoneyMax="+jlFwMoneyMax+"&progressMin="+progressMin+"&checkShape="+checkShape
            +"&progressMax="+progressMax+"&hkjsx="+hkjsx+"&province="+province+"&city="+city+"&county="+county+"&startDate="+startDate+"&endDate="+endDate
            +"&hkblmin="+hkblmin+"&hkblmax="+hkblmax+"&qfblmin="+qfblmin+"&qfblmax="+qfblmax+"&tjType="+tjType+"&startWjDate="+startWjDate+"&endWjDate="+endWjDate;
        location.href = url;
    }
    $(function () {
        //回车事件
        $(document).keydown(function(e){
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                query();
            }
            return true;
        });
    })
    // 重置
    function resetQuery(){
        $("#projectOwner").val('');
        $("#projectName").val('');
        $("#projectType").val('');
        $("#checkShape").val('');
        $("#hyType").val('');
        $("#status").val('');
        $("#projectManagerPersonName").val('');
        $("#technologyPersonName").val('');
        $("#isYq").val('');
        $("#hkjsx").val('');
        $("#province").val('');
        $("#city").val('');
        $("#county").val('');
        $("#tzMoneyMin").val('');
        $("#tzMoneyMax").val('');
        $("#progressMin").val('');
        $("#progressMax").val('');
        $("#htMoneyMin").val('');
        $("#htMoneyMax").val('');
        $("#startDate").val('');
        $("#endDate").val('');

        $("#hkblmin").val('');
        $("#hkblmax").val('');
        $("#qfblmin").val('');
        $("#qfblmax").val('');
        $("#selectedOption").val('day');
        selectChange()
        var tjType= $("#selectedOption").val();
        let genTimeEnd = genTime('day');
        $("#endWjDate").val(genTimeEnd)
        let genTimeStart = genTimeLastDay('day');
        $("#startWjDate").val(genTimeStart)

        var jsondata = {
            projectOwner:"",
            projectName: "",
            projectType: "",
            hyType:"",
            status:"",
            projectManagerPersonName:"",
            supervisorEngineerName:"",
            progress:"",
            isYq:"",
            tzMoneyMin:"",
            tzMoneyMax:"",
            htMoneyMin:"",
            htMoneyMax:"",
            progressMin:"",
            progressMax:"",
            hkjsx:"",
            province: "",
            city: "",
            county: "",
            startDate: "",
            endDate: "",
            technologyPersonName:"",
            checkShape:"",
            tjType:tjType,
            startWjDate:startWjDate,
            endWjDate:endWjDate,
        };
        $("#checkShape").empty();
        table.reload('tableList', {where: jsondata});
    }
</script>
</body>

</html>
